/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.udesc.db;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author anderson
 */
@Entity
@Table(name = "bancos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Bancos.findAll", query = "SELECT b FROM Bancos b"),
    @NamedQuery(name = "Bancos.findById", query = "SELECT b FROM Bancos b WHERE b.id = :id"),
    @NamedQuery(name = "Bancos.findByNome", query = "SELECT b FROM Bancos b WHERE b.nome = :nome"),
    @NamedQuery(name = "Bancos.findByAgencia", query = "SELECT b FROM Bancos b WHERE b.agencia = :agencia"),
    @NamedQuery(name = "Bancos.findByNumero", query = "SELECT b FROM Bancos b WHERE b.numero = :numero"),
    @NamedQuery(name = "Bancos.findByTelefone", query = "SELECT b FROM Bancos b WHERE b.telefone = :telefone"),
    @NamedQuery(name = "Bancos.findByFax", query = "SELECT b FROM Bancos b WHERE b.fax = :fax"),
    @NamedQuery(name = "Bancos.findByContato", query = "SELECT b FROM Bancos b WHERE b.contato = :contato"),
    @NamedQuery(name = "Bancos.findByDataCadastramento", query = "SELECT b FROM Bancos b WHERE b.dataCadastramento = :dataCadastramento")})
public class Bancos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "nome")
    private String nome;
    @Column(name = "agencia")
    private Integer agencia;
    @Column(name = "numero")
    private Integer numero;
    @Size(max = 15)
    @Column(name = "telefone")
    private String telefone;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Formato de telefone/fax inválido, deve ser xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Size(max = 15)
    @Column(name = "fax")
    private String fax;
    @Size(max = 45)
    @Column(name = "contato")
    private String contato;
    @Basic(optional = false)
    @NotNull
    @Column(name = "data_cadastramento")
    @Temporal(TemporalType.DATE)
    private Date dataCadastramento;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "banco")
    private List<ChequesEmitidos> chequesEmitidosList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "banco")
    private List<ChequesRecebidos> chequesRecebidosList;
    @JoinColumn(name = "logradouro", referencedColumnName = "id")
    @ManyToOne
    private Logradouros logradouro;
    @JoinColumn(name = "cidade", referencedColumnName = "id")
    @ManyToOne
    private Cidades cidade;

    public Bancos() {
    }

    public Bancos(Integer id) {
        this.id = id;
    }

    public Bancos(Integer id, String nome, Date dataCadastramento) {
        this.id = id;
        this.nome = nome;
        this.dataCadastramento = dataCadastramento;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public Integer getAgencia() {
        return agencia;
    }

    public void setAgencia(Integer agencia) {
        this.agencia = agencia;
    }

    public Integer getNumero() {
        return numero;
    }

    public void setNumero(Integer numero) {
        this.numero = numero;
    }

    public String getTelefone() {
        return telefone;
    }

    public void setTelefone(String telefone) {
        this.telefone = telefone;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getContato() {
        return contato;
    }

    public void setContato(String contato) {
        this.contato = contato;
    }

    public Date getDataCadastramento() {
        return dataCadastramento;
    }

    public void setDataCadastramento(Date dataCadastramento) {
        this.dataCadastramento = dataCadastramento;
    }

    @XmlTransient
    public List<ChequesEmitidos> getChequesEmitidosList() {
        return chequesEmitidosList;
    }

    public void setChequesEmitidosList(List<ChequesEmitidos> chequesEmitidosList) {
        this.chequesEmitidosList = chequesEmitidosList;
    }

    @XmlTransient
    public List<ChequesRecebidos> getChequesRecebidosList() {
        return chequesRecebidosList;
    }

    public void setChequesRecebidosList(List<ChequesRecebidos> chequesRecebidosList) {
        this.chequesRecebidosList = chequesRecebidosList;
    }

    public Logradouros getLogradouro() {
        return logradouro;
    }

    public void setLogradouro(Logradouros logradouro) {
        this.logradouro = logradouro;
    }

    public Cidades getCidade() {
        return cidade;
    }

    public void setCidade(Cidades cidade) {
        this.cidade = cidade;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Bancos)) {
            return false;
        }
        Bancos other = (Bancos) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nome;
    }
    
}
